package com.lbssoft.gpsbd.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface DeviceGeofenceMapper {
	
	/**
	 * 围栏设备绑定
	 */
	@Insert("INSERT INTO lbs_device_geofence(deviceId,geofenceId) VALUE(#{deviceId},#{geofenceId})")
	void addDeviceGeofence(@Param("deviceId") long deviceId,@Param("geofenceId") long geofenceId);

	/**
	 * 根据围栏id获取绑定的设备ids
	 * @param geofenceId
	 * @return
     */
	@Select("SELECT * FROM lbs_device_geofence WHERE geofenceid =#{geofenceId}")
	List<Integer> getDeviceIds(@Param("geofenceId") long geofenceId);

	/**
	 * 删除
	 * @param deviceId
	 * @param geofenceId
     */
	@Delete("DELETE  FROM lbs_device_geofence WHERE geofenceid = #{geofenceId} AND deviceid =  #{deviceId}")
	void delete(@Param("deviceId") long deviceId,@Param("geofenceId") long geofenceId);
	
	/**
	 * 根据设备id获取绑定的围栏ids
	 * @param deviceId
	 * @return
     */
	@Select("SELECT geofenceId FROM lbs_device_geofence WHERE deviceId =#{deviceId}")
	List<Integer> getGeofenceIds(@Param("deviceId") long deviceId);
}
